// JavaScript Document
var auction = {
	list: function (status, pageSize) {
		var data = { status: status, pageNum: pageNum = null ? pageNum : 1, pageSize: pageSize = null ? CONFIG.pageSize : pageSize };
		$.commonAjax({
			url: 'B049',
			type: 'POST',
			data: data,
			isShowError: true,
			success: function (res) {
				var htm = '';
				$.each(res.data.data, function (k, v) {
					console.log(v);
					htm += '<li class="tab-list">';
					htm += '    <div onClick="auction.delet(\'' + v.code + '\')" class="remove"></div>';
					htm += '    <div class="tab-list-box">';
					htm += '        <div class="shopImg">';
					htm += '            <img src="' + CONFIG.imgUrl +(v.goods.iconImages==null?'': v.goods.iconImages.mediumUrl )+ '" alt="">';
					htm += '        </div>';
					htm += '        <div class="shopInfo">';
					htm += '            <div class="shopTit">' + v.goods.name + '</div>';
					htm += '            <div class="shopMoney">起拍价：<span>' + (v.startingPrice != null ? v.goods.startingPrice : '起拍价待定') + '</span></div>';
					htm += '            <div class="addMoney">加价幅度：' + (v.amplitudePrice != null ? v.goods.amplitudePrice : '待定') + '</div>';
					htm += '            <div class="startTime">开始时间：' + (v.startTime == null ? '待定' : bp.timestamp_to_date(Number(v.startTime))) + '</div>';
					htm += '            <div class="endTime">结束时间：' + (v.endTime == null ? '待定' : bp.timestamp_to_date(Number(v.endTime))) + '</div>';
					htm += '            <div class="state">状态：' + v.statusDesc + '</div>';
					htm += '        </div>';
					htm += '    </div>';
					htm += '    <div class="operation-box">';
					htm += '        <div onClick="bp.jump_data(\'entrust1.html?code='+v.code+'\')" class="edit"><span class="editIcon"></span>编辑</div>';
					htm += '        <div onClick="auction.submit(\'' + v.code + '\')" class="examine"><span class="examineIcon"></span>提交审核</div>';
					htm += '        <div onClick="bp.jump_data(\'details.html?goodsCode=' + v.goods.code + '&auctionCode='+v.code+ '\')" class="details"><span class="detailsIcon"></span>查看详情</div>';
					htm += '    </div>';
					htm += '</li>';
				})
				$('.tap0').html(htm);
			}, error: function (res) {
				$.layermsg(res.msg);
			}
		});
	}, delet: function (goodsCode) {
		//
		var data = { auctionCode: goodsCode };
		$.commonAjax({
			url: 'B087',
			type: 'POST',
			data: data,
			isShowError: true,
			success: function (res) {
				$.layermsg(res.msg);
				if(res.code==200){
					setTimeout(function(){
						window.location.href = '';
					},1500)
				}
			}, error: function (res) {
				$.layermsg(res.msg);
			}
		});
	}, edit: function () {

	}, submit: function (goodsCode) {
		var data = { auctionCode: goodsCode };
		$.commonAjax({
			url: 'B070',
			type: 'POST',
			data: data,
			isShowError: true,
			success: function (res) {
				$.layermsg(res.msg);
			}, error: function (res) {
				$.layermsg(res.msg);
			}
		});
	}
}

$(function () {
	auction.list(1, null);
	$(".nav-list").click(function () {
		$(this).addClass("nav-list-active").siblings().removeClass("nav-list-active");
		auction.list($(this).index() + 1, null);
	})
})